import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BuyRecordVO, BuyRecordForm, BuyRecordQuery } from '@/api/bus/buyRecord/types';

/**
 * 查询购买记录列表
 * @param query
 * @returns {*}
 */

export const listBuyRecord = (query?: BuyRecordQuery): AxiosPromise<BuyRecordVO[]> => {
  return request({
    url: '/bus/buyRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询购买记录详细
 * @param id
 */
export const getBuyRecord = (id: string | number): AxiosPromise<BuyRecordVO> => {
  return request({
    url: '/bus/buyRecord/' + id,
    method: 'get'
  });
};

/**
 * 新增购买记录
 * @param data
 */
export const addBuyRecord = (data: BuyRecordForm) => {
  return request({
    url: '/bus/buyRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改购买记录
 * @param data
 */
export const updateBuyRecord = (data: BuyRecordForm) => {
  return request({
    url: '/bus/buyRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除购买记录
 * @param id
 */
export const delBuyRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/bus/buyRecord/' + id,
    method: 'delete'
  });
};

/**
 * 套餐购买支付
 * 根据当前登录账号套餐购买
 * @param data
 */
export const payHtAccountByLoginUser = (data: any) => {
  return request({
    url: '/bus/jqtCpHtOrder/payHtAccountByLoginUser',
    method: 'post',
    data: data
  });
};

